/** \brief File declaring a class storing the rules.
 *
 * This file contains the declaration of a class which stores the game rules.
 *
 * @file RuleData.hpp
 * @author Johan "Solo" Luisier
 * @date 2013/04/24
 */
#ifndef RULEDATA_HPP
#define RULEDATA_HPP

#include <QtCore/QList>

/** @brief Class implementing the storage of the game rules.
 *
 * This class implements the storage of the game rules, i.e. the survival and
 * birth conditions.
 *
 * @author Johan "Solo" Luisier
 * @date 2013/04/24
 */
class RuleData
{
public:
    /** @brief Constructor, initialises the data members.
     *
     * The constructor sets the maximal number of neighbours a cell can have.
     *
     * @param[in] maxNeighbours maximum number of neighbours of a cell.
     */
    RuleData( const quint8& maxNeighbours = 8u );
    /** @brief Destructor, @c virtual to ensure a proper destruction sequence.
     *
     * The destructor clears the two QList members.
     */
    virtual ~RuleData();
    /** \brief Getter for MaxNeighbours.
     *
     * This method allows to access MaxNeighbours.
     *
     * @return a const reference on MaxNeighbours.
     */
    inline const quint8& maxNeighbours() const { return MaxNeighbours; }
    /** @brief Getter for BirthConditions.
     *
     * This method allows to access BirthConditions.
     *
     * @return a const reference on BirthConditions.
     */
    inline const QList< quint8 >& birthConditions() { return BirthConditions; }
    /** @brief Setter for BirthConditions.
     *
     * This method allows to modify BirthConditions.
     *
     * @param[in] bConds new values for BirthConditions.
     */
    inline void setBirthConditions( const QList< quint8 >& bConds ) { BirthConditions = bConds; }
    /** @brief Method allowing to add a birth condition.
     *
     * This method allows to add a birth condition for a Cell instance. If the
     * added value is already present in BirthCondition, it is not added.
     *
     * @param[in] bCond value of the new birth condition.
     *
     * @retval true if the new birth condition could be added,
     * @retval false if the birth condition already existed or is higher than
     * MaxNeighbours and was not added.
     */
    bool addBirthCondition( const quint8& bCond );
    /** @brief Method allowing to remove a birth condition.
     *
     * This method allows to remove a birth condition for a Cell instance. If
     * the value to remove doesn't exist, the method does nothing.
     *
     * @param[in] bCond value of the birth condition to remove.
     *
     * @retval true if the birth condition was found and removed successfully,
     * @retval false if the condition doesn't exist.
     */
    bool removeBirthCondition( const quint8& bCond );
    /** @brief Method allowing to reset the birth conditions.
     *
     * This method allows to clear the BirthConditions container.
     */
    inline void clearBirthConditions() { BirthConditions.clear(); }
    /** @brief Getter for SurvivalConditions.
     *
     * This method allows to access SurvivalConditions.
     *
     * @return a const reference on SurvivalConditions.
     */
    inline const QList< quint8 >& survivalConditions() { return SurvivalConditions; }
    /** @brief Setter for SurvivalConditions.
     *
     * This method allows to modify SurvivalConditions.
     *
     * @param[in] sConds new values for SurvivalConditions.
     */
    inline void setSurvivalConditions( const QList< quint8 >& sConds ) { SurvivalConditions = sConds; }
    /** @brief Method allowing to add a survival condition.
     *
     * This method allows to add a survival condition for a Cell instance. If
     * the added value is already present in SurvivalConditions, it is not
     * added.
     *
     * @param[in] sCond value of the new survival condition.
     *
     * @retval true if the new survival condition could be added,
     * @retval false if the survival condition already existed or is higher than
     * MaxNeighbours and was not added.
     */
    bool addSurvivalCondition( const quint8& sCond );
    /** @brief Method allowing to remove a survival condition.
     *
     * This method allows to remove a survival condition for a Cell instance.
     * If the value to remove doesn't exist, the method does nothing.
     *
     * @param[in] sCond value of the survival condition to remove.
     *
     * @retval true if the survival condition was found and removed
     * successfully, @retval false if the condition doesn't exist.
     */
    bool removeSurvivalCondition( const quint8& sCond );
    /** @brief Method allowing to reset the survival conditions.
     *
     * This method allows to clear the SurvivalConditions container.
     */
    inline void clearSurvivalConditions() { SurvivalConditions.clear(); }
protected:
    /** @brief Maximal number of neighbours.
     *
     * This value is used to check when a rule is added.
     */
    quint8 MaxNeighbours;
    /** @brief List of birth conditions.
     *
     * This container is used to set the birth conditions for each created Cell
     * instance.
     */
    QList< quint8 > BirthConditions;
    /** @brief List of survival conditions.
     *
     * This container is used to set the survival conditions for each created
     * Cell instance.
     */
    QList< quint8 > SurvivalConditions;
};

#endif // RULEDATA_HPP
